(in-package clim-user)

(define-application-frame frame-full-name ()
  ((f-name :accessor f-name :initform nil) 
   (l-name :accessor l-name :initform nil))
  (:panes 
   ;; one pane to show the name
   (pane-full-name 
    :application
    :incremental-redisplay t
    :initial-cursor-visibility nil
    :redisplay-after-commands t
    :display-function 'display-pane-full-name))
  (:layouts
   (default pane-full-name)))

(defmethod display-pane-full-name ((frame frame-full-name) stream)
  (when (and (l-name frame) (f-name frame))
    (write-string (format nil "~%    ~A, ~A" (l-name frame) (f-name frame)) stream)))

(define-frame-full-name-command (get-name :menu "Get Name")
    ()
  (let (f-name l-name
	(stream (frame-standard-input *application-frame*)))
    (restart-case
	(progn
	  (accepting-values (stream :own-window t
				    :label "Input Values"
				    :initially-select-query-identifier 'selected)
	    (formatting-table (stream)
	      (formatting-column (stream)
		(formatting-cell (stream)
		  (setq f-name (accept 'string 
				       :prompt "First Name" :stream stream :query-identifier 'selected)))
		(formatting-cell (stream)
		  (setq l-name (accept 'string
				       :prompt "Last Name" :stream stream))))))
	  ;; This gets done if the accepting-values dialog is not canceled
	  (cond ((and f-name l-name)
		 (setf (f-name *application-frame*) f-name)
		 (setf (l-name *application-frame*) l-name))
		(t (notify-user *application-frame* "A Field was left blank"))))
      (abort () ()))))

(run-frame-top-level (make-application-frame 'frame-full-name :width 300))